<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var a = [1,2,4,5,6,7,8];
        var b = 0;
        for(var i=0;i<a.length;i++){
            if(a[i]>3){
                b= i;
                break;
            }
        }
        function c(arr,n,data){
            for(var j=arr.length;j>=n;j--){
                arr[j] = arr[j-1];
            }
            arr[n] = data;
        }
        c(a,b,3);
        console.log(a);
    </script>
</body>
</html>